package demo3;
//懒汉模式，不安全
class Singleton2{
    private static Singleton2 instance=null;
    public static Singleton2 getInstance(){
        if (instance==null){//读
            instance=new Singleton2();//修改
        }
        return instance;
    }
    private Singleton2(){

    }
}
public class test {
    public static void main(String[] args) {
       Singleton2 t1= Singleton2.getInstance();
        Singleton2 t2= Singleton2.getInstance();

        System.out.println(t1==t2);
    }
}

